document.write('<style>'+
'.shr-connected { margin: 10px 0 10px 0; padding: 10px; }'+
'.shr-email { font-size:12px; overflow: hidden; margin:0 5px 0 5px; width:100px; height:77.5px; border-right: 1px solid silver;}' +
'.shr-email a {color: #256F94;text-decoration:none; }' +
'.shr-email a:hover {color: #BC6637;}' +
'.shr-email a:focus {outline: none;}' +
'</style>');


if (typeof num_post != "undefined") {
    if (typeof num_url != "undefined") {

        var randarray = new Array();
        var l = 0; var flag;
        var numofpost = num_post;

        function randomposts(json) {
            var total = parseInt(json.feed.openSearch$totalResults.$t, 10);
            for (i = 0; i < numofpost; ) {
                flag = 0; randarray.length = numofpost; l = Math.floor(Math.random() * total); for (j in randarray) { if (l == randarray[j]) { flag = 1; } }
                if (flag == 0 && l != 0) { randarray[i++] = l; }
            } document.write("<div class='shr-connected'><table><tr>");

            imgr = new Array();
            imgr[0] = "http://2.bp.blogspot.com/-uitX7ROPtTU/Tyv-G4NA_uI/AAAAAAAAFBY/NcWLPVnYEnU/s1600/no+image.jpg";
            showRandomImg = true;
            j = (showRandomImg) ? Math.floor((imgr.length + 1) * Math.random()) : 0;
            img = new Array();

            for (n in randarray) {
                var p = randarray[n]; var entry = json.feed.entry[p - 1];
                for (k = 0; k < entry.link.length; k++) {
                    if (entry.link[k].rel == 'alternate') {
                        if ("content" in entry) {
                            var postcontent = entry.content.$t;
                        }
                        else
                            if ("summary" in entry) {
                                var postcontent = entry.summary.$t;
                            }
                            else var postcontent = "";

                        postdate = entry.published.$t;

                        if (j > imgr.length - 1) j = 0;
                        img[i] = imgr[j];

                        s = postcontent; a = s.indexOf("<img"); b = s.indexOf("src=\"", a); c = s.indexOf("\"", b + 5); d = s.substr(b + 5, c - b - 5);

                        if ((a != -1) && (b != -1) && (c != -1) && (d != "")) img[i] = d;

                        var item = "<td><div class='shr-email'><a href='" + entry.link[k].href + "'><img width='80' height='90' src='" + img[i] + "'/></a></div><div class='shr-email'> <a href='" + entry.link[k].href + "'>" + entry.title.$t + "</a></div></td>";

                        document.write(item);
                    }
                }
            } document.write("</tr></table></div>");
        }
        document.write('<script src="http://'+ num_url +'/feeds/posts/default?alt=json-in-script&start-index=1&max-results=1000&callback=randomposts" type="text/javascript"></script>');
    }
}
